<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'reply-follow', //页面标示
    'pagename' => '关注自动回复设置', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/fuelux/fuelux','content/combodate/moment.min','content/combodate/combodate'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<section id="content">
  <section class="main padder">
    <div class="clearfix">
      <h4><i class="fa fa-edit"></i><?php echo trim($Document['pagename'],'_');?></h4>
    </div>
    <div class="row">
      <div class="col-sm-12">
      <!---->
      <div class="block">
          <a class="btn btn-default" href="<?php echo U('reply/add');?>">添加回复</a>
          <div class="btn-group" style="margin-left:20px">
              <a class="btn btn-white" href="<?php echo U('reply/follow');?>">关注自动回复</a>
              <a class="btn btn-white" href="<?php echo U('reply/index');?>">关键词回复</a>
          </div>
      </div>
      <!---->
        <section class="panel">
          <div class="panel-body">
            <form class="form-horizontal" method="post" id="Form1">
              <!--用户关注自动推送-->
              <div class="form-group">
                <label class="col-sm-1 control-label">用户关注自动推送</label>
                <div class="col-sm-10">
                  <div class="row">
                <?php
					$showType=0;
					foreach($replyType as $key=>$val){
				?>
                    <div class="col-xs-1 radio m-l-large select_reply_type">
                      <label class="radio-custom">
                        <input type="radio" name="reply_type" value="<?php echo $key;?>" <?php if ($key==$rs['reply_type']){$showType=$key; echo 'checked="checked"';}?>/>
                        <i class="fa fa-circle-o <?php if ($key==$rs['reply_type']){$showType=$key; echo 'checked';}?>"></i><?php echo $val;?></label>
                    </div>
               <?php
					}
				?>
                  </div>
                  <p class="help-block">当用户关注时，会自动推送给用户，通常这里放置欢迎语及账号帮助信息</p>
                </div>
              </div>
              <!--回复内容-->
              <div class="item_reply_type" <?php if ($rs['reply_type']!=0){echo 'style="display:none"';}?>>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">回复内容</label>
                    <div class="col-sm-8">
                      <p><a href="<?php echo U('face/index',array('id'=>'subscribe'));?>" rel="pop">添加表情</a></p>
                      <textarea class="form-control" name="subscribe" id="subscribe" style="height:200px"><?php echo $rs['subscribe'];?></textarea>
                      <p class="help-block">文本内容支持html代码（A标签）</p>
                    </div>
                  </div>
                  <!--是否显示帐号绑定-->
                  <div class="form-group">
                    <label class="col-sm-1 control-label">是否显示帐号绑定</label>
                    <div class="col-sm-5">
                      <div class="row">
                        <div class="col-xs-3 radio m-l-large">
                          <label class="radio-custom">
                            <input name="show_bind" type="radio" value="1" <?php if ($rs['show_bind']){echo 'checked';}?>/>
                            <i class="fa fa-circle-o <?php if ($rs['show_bind']){echo 'checked';}?>"></i>是</label>
                        </div>
                        <div class="col-xs-3 radio m-l-large">
                          <label class="radio-custom">
                            <input type="radio" name="show_bind"  value="0" <?php if (!$rs['show_bind']){echo 'checked';}?>/>
                            <i class="fa fa-circle-o <?php if (!$rs['show_bind']){echo 'checked';}?>"></i>否</label>
                        </div>
                      </div>
                      <p class="help-block">当用户关注时，会提示用户绑定帐户信息</p>
                    </div>
                  </div>
              </div>
              <!--回复图文-->
              <div class="form-group item_reply_type" <?php if ($rs['reply_type']!=1){echo 'style="display:none"';}?>>
                <label class="col-sm-1 control-label">图文列表</label>
                <div class="col-sm-4">
                  <select name="id" class="form-control" id="id">
                    <?php
					if ($news){
						foreach($news as $val){
					?>
                    <option value="<?php echo $val['id'];?>" <?php if ($rs['reply_type']==1&&$rs['id']==$val['id']){echo 'selected';}?>><?php echo $val['title'].'['.$newsType[$val['type']].']';?></option>
                    <?php
						}
					}else{
						echo '<option value="0">请先添加图文素材</option>';	
					}
					?>
                  </select>
                  <p class="help-block">只会显示最新20条</p>
                </div>
              </div>
              <!--回复动作-->
              <div class="form-group item_reply_type" <?php if ($rs['reply_type']!=2){echo 'style="display:none"';}?>>
                <label class="col-sm-1 control-label">动作列表</label>
                <div class="col-sm-4">
                  <select name="action_id" class="form-control" id="action_id">
                    <?php
					  if ($action){
						  foreach($action as $key=>$val){
					  ?>
                    <option value="<?php echo $key;?>" <?php if ($rs['reply_type']==2&&$rs['fid']==$key){echo 'selected';}?>><?php echo $val;?></option>
                    <?php
						  }
					  }else{
						  echo '<option value="0">请先添加动作</option>';	
					  }
					  ?>
                  </select>
                  <p class="help-block"></p>
                </div>
              </div>
              <!--无结果时自动回复-->
              <div class="form-group">
                <label class="col-sm-1 control-label">无结果时自动回复</label>
                <div class="col-sm-10">
                  <div class="row">
                    <?php
						$showType=0;
						foreach($replyType as $key=>$val){
					?>
                    <div class="col-xs-1 radio m-l-large select_no_result_type">
                      <label class="radio-custom">
                        <input type="radio" name="no_result_type" value="<?php echo $key;?>" <?php if ($key==$rs['no_result_type']){$showType=$key; echo 'checked="checked"';}?>/>
                        <i class="fa fa-circle-o <?php if ($key==$rs['no_result_type']){$showType=$key; echo 'checked';}?>"></i><?php echo $val;?></label>
                    </div>
                    <?php
						}
					?>
                  </div>
                  <p class="help-block">当用户输入的内容不存在自动回复时会自动推送答复用户</p>
                </div>
              </div>
              <!--回复内容-->
              <div class="form-group item_no_result_type" <?php if ($rs['no_result_type']!=0){echo 'style="display:none"';}?>>
                <label class="col-sm-1 control-label">回复内容</label>
                <div class="col-sm-8">
                  <p><a href="<?php echo U('face/index',array('id'=>'no_result'));?>" rel="pop">添加表情</a></p>
                  <textarea class="form-control" id="no_result" name="no_result"  style="height:200px"><?php echo $rs['no_result'];?></textarea>
                  <p class="help-block">文本内容支持html代码（A标签）</p>
                </div>
              </div>
              <!--图文列表-->
              <div class="form-group item_no_result_type" <?php if ($rs['no_result_type']!=1){echo 'style="display:none"';}?>>
                <label class="col-sm-1 control-label">图文列表</label>
                <div class="col-sm-4">
                  <select name="no_result_id" class="form-control" id="no_result_id">
                    <?php
					  if ($news){
						  foreach($news as $val){
					  ?>
                    <option value="<?php echo $val['id'];?>" <?php if ($rs['no_result_type']==1&&$rs['no_result_id']==$val['id']){echo 'selected';}?>><?php echo $val['title'].'['.$newsType[$val['type']].']';?></option>
                    <?php
						}
					}else{
						echo '<option value="0">请先添加图文素材</option>';	
					}
					?>
                  </select>
                  <p class="help-block">只会显示最新20条</p>
                </div>
              </div>
              <!--回复动作-->
              <div class="form-group item_no_result_type" <?php if ($rs['no_result_type']!=2){echo 'style="display:none"';}?>>
                <label class="col-sm-1 control-label">动作列表</label>
                <div class="col-sm-4">
                  <select name="action_id" class="form-control" id="action_id">
                    <?php
					if ($action){
						foreach($action as $key=>$val){
					?>
                    <option value="<?php echo $key;?>" <?php if ($rs['reply_type']==2&&$rs['fid']==$key){echo 'selected';}?>><?php echo $val;?></option>
                    <?php
						}
					}else{
						echo '<option value="0">请先添加动作</option>';	
					}
					?>
                  </select>
                  <p class="help-block"></p>
                </div>
              </div>
              <!---->
              <div class="form-group">
                <div class="col-sm-9 col-lg-offset-1">
                  <div class="col-sm-1">
                    <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
                  </div>
                  <div class="col-md-offset-2">
                    <button type="button" class="btn btn-white">取消</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<!--主体 结束--> 
<script>
    $(function() {
		$('.select_reply_type').click(function(){
			$('.item_reply_type').hide().eq($(this).index()).show();
		})
		$('.select_no_result_type').click(function(){
			$('.item_no_result_type').hide().eq($(this).index()).show();
		})
        $("#Form1").submit(function() {
			Msg.loading();
            $.post('<?php echo U('reply/savefollow') ?>', $(this).serialize(), function(result) {
				Msg.hide();
				resetSubmit("#sub-ok",'保存');
                if (result.status == 1) {
                    Msg.ok(result.info);
                } else {
                    Msg.error(result.info);
                }
            }, "json");
            return false;
        })
    })
</script>
<?php
include getTpl('footer', 'public');
?>
